package com.regexs;

/**
 * @className: Test1
 * @description: TODO 类描述
 * @author: YUANG
 * @date: 2021/12/29
 **/
public class Test1 {
    public static void main(String[] args) {
//        test01();
        String regex1 = "abc";
        System.out.println("abc".matches(regex1));
        System.out.println("aBc".matches(regex1));
        System.out.println("ac".matches(regex1));

        System.out.println("---------------------------------");

        String regex2 = "a\\&c";
        System.out.println("a&c".matches(regex2));
        System.out.println("a-c".matches(regex2));
        System.out.println("a&&c".matches(regex2));

        System.out.println("---------------------------------");

        String regex3 = "00\\d";
        System.out.println("001".matches(regex3));
        System.out.println("00a".matches(regex3));

        System.out.println("---------------------------------");

        String regex4 = "a\\sc";
        System.out.println("a c".matches(regex4));

        System.out.println("---------------------------------");

        String regex5 = "a\\d*";

        System.out.println("a11".matches(regex5));
        System.out.println("a1".matches(regex5));
        System.out.println("aa".matches(regex5));

        System.out.println("---------------------------------");

        String regex6 = "a\\d+";

        System.out.println("a11".matches(regex6));
        System.out.println("a1".matches(regex6));
        System.out.println("a".matches(regex6));

        System.out.println("---------------------------------");

        String regex7 = "a\\d{2,3}";

        System.out.println("a11".matches(regex7));
        System.out.println("a1".matches(regex7));
        System.out.println("a22222".matches(regex7));
        System.out.println("---------------------------------");

        //010-12345678
        String regex8 = "\\d{3,4}-\\d{7,8}";
        System.out.println("010-12345678".matches(regex8));
        System.out.println("0111-12345678".matches(regex8));
    }

    private static void test01() {
        String regex = "20\\d\\d";
        System.out.println("2019".matches(regex));
        System.out.println("201a".matches(regex));
    }
}
